<script lang="ts" setup>
import API from '@/services';
import AQueryTable from '@dangojs/a-query-table';
import { reactive } from 'vue';

const props = defineProps<{id: number | string}>()
const columns = [
  {
    title: '指标名称',
    dataIndex: 'metricsName'
  },
  {
    title: '指标类型',
    dataIndex: 'metricsTypeName'
  }
];
const requestData = async (query: any) => {
  try {
    const { data } = await API.dataModel.postGetModelMetricsPage({ ...query });
    return {
      success: true,
      data: data?.list || [],
      total: data?.total || 0
    };
  } catch {
    return {
      success: true,
      data: [],
      total: 0
    };
  }
};
const params = reactive({
  modelId: props.id,
  name: ''
});
const onChange = (name: any) => {
  params.name = name;
};
</script>
<template>
  <div class="p-18">
    <a-input-search :style="{ width: '200px', marginBottom: '12px' }" placeholder="开始搜索" @change="onChange" />
    <AQueryTable
      ref="querytableRef"
      :columns="columns"
      :request="requestData"
      :params="params"
    >
    </AQueryTable>
  </div>
</template>
